package com.k136.controller;
import com.k136.entity.Driverschool;
import com.k136.service.DriverschoolService;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * TODO 类
 * @author LiuTai
 * @version 1.00
 * @Date 2024/11/8
 */
@RestController
@RequestMapping("/driverschool")
public class DriverschoolController {
    @Resource
    private DriverschoolService driverschoolService;
    @RequestMapping("selAll/{pageNo}")
    public String selAll(
            @PathVariable("pageNo") Integer pageNo,
            @RequestParam(required = false) Integer xzid,
            Model model) {
        model.addAttribute("person", driverschoolService.selDriverschool(xzid, pageNo, 2));
        return "selAll";
    }
    @RequestMapping("sel/{id}")
    public String sel(
            @PathVariable("id")Integer id,
            Model model){
        model.addAttribute("xg",driverschoolService.selDriverschoolById(id));
        return "xg";
    }
    @RequestMapping("xg")
    public String xg(
          Driverschool driverschool
    ){

        if (driverschoolService.updDriverschoolById(driverschool)){
            return "redirect:/driverschool/selAll/1";
        }else {
            return "redirect:/driverschool/sel/"+driverschool.getId();
        }
    }
}